package DAO;

import java.util.HashMap;
import java.util.Map;

import rdbms.RDBMSDAOFactory;



public abstract class DAOFactoryRDBMS {

	// List of DAO types supported by the factory
	public static enum FACTORY_TYPE {
		GENERIC_RDBMS, POSTGRE_RDBMS
	};

	private static Map<FACTORY_TYPE, DAOFactoryRDBMS> factoriesMap;

	static {
		DAOFactoryRDBMS.initializeRDBMSFactories();
	}

	private static void initializeRDBMSFactories() {
		DAOFactoryRDBMS.factoriesMap = new HashMap<FACTORY_TYPE, DAOFactoryRDBMS>();
		factoriesMap.put(FACTORY_TYPE.GENERIC_RDBMS, new RDBMSDAOFactory());
		//factoriesMap.put(FACTORY_TYPE.POSTGRE_RDBMS, new POSTGREDAOFactory());
	}

	public abstract ENSequenceDAO getENSequenceDAO(final String idConnection)
			throws Exception;

	public abstract DateDAO getDateDAO(final String idConnection)
			throws Exception;

	public abstract DIClassDAO getDIClassDAO (final String idConnection,
			final ENSequenceDAO sequence) throws Exception;

	public abstract DIConceptDAO getDIConceptDAO(final String idConnection,
			final ENSequenceDAO sequence) throws Exception;

	public abstract DIConceptDomainDAO getDIConceptDomainDAO(final String idConnection,
			final ENSequenceDAO sequence) throws Exception;

	public abstract DIDomainDAO getDIDomainDAO(final String idConnection,
			final ENSequenceDAO sequence) throws Exception;

	public abstract DITermDAO getDITermDAO(final String idConnection,
			final ENSequenceDAO sequence) throws Exception;

	public abstract FTConceptTimeDAO getFTConceptTimeDAO(final String idConnection)
			throws Exception;

	public abstract FTRelationTimeDAO getFTRelationTimeDAO(final String idConnection)
			throws Exception;

	public abstract RelationDAO getRelation(final String idConnection)
			throws Exception;

	public static DAOFactoryRDBMS getDAOFactory(final FACTORY_TYPE factoryType) {
		return DAOFactoryRDBMS.factoriesMap.get(factoryType);
	}

	public static DAOFactoryRDBMS.FACTORY_TYPE getType(final String jdbcDriver) {
		DAOFactoryRDBMS.FACTORY_TYPE type = DAOFactoryRDBMS.FACTORY_TYPE.GENERIC_RDBMS;
		if (jdbcDriver.indexOf("hsqldb") != -1)
			type = DAOFactoryRDBMS.FACTORY_TYPE.POSTGRE_RDBMS;
		return type;
	}

}
